package comxin.demo1;

import org.junit.Test;

import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;

public class GeneriTest1 {

    //测试泛型类
    @Test
    public void method1(){
        Generic generic=new Generic();
        generic.setT("张三");
        System.out.println(generic.getT());
        Generic generic1=new Generic();
        generic1.setT(1);
        System.out.println(generic1.getT());
    }

    //测试类型通配符
    @Test
    public void method2(){
        List<?> list=new ArrayList<Object>();
        List<?> list1=new ArrayList<Number>();
        List<?> list2=new ArrayList<Integer>();
        System.out.println("-------------------");
        List<? extends Number> list3=new ArrayList<Number>();
        List<? extends Number> list4=new ArrayList<Integer>();
    }
    public void method3(){
        List<?> list=new ArrayList<>();
        List list1=new ArrayList<>();
    }
}
